package com.abe.mvp.presenter;

import com.abe.mvp.contact.WebServerContact;
import com.abe.mvp.contact.WebServerContact.Model.IWebServerBack;
import com.abe.mvp.model.WebServerModelImp;
import com.abe.mvp.model.bean.http.VersionBean;

public class HttpVersionPresenter implements WebServerContact.VersionPresenter {

	private WebServerContact.Model mModel;
	private WebServerContact.VersionUpdateView mView;

	public HttpVersionPresenter(WebServerContact.VersionUpdateView mView) {
		this.mView = mView;
		this.mModel = new WebServerModelImp();
	}

	@Override
	public void getVersionInfo() {
		mModel.getVersionInfo(new IWebServerBack() {
			@Override
			public void onResult(int code, Object data, String errorMSG) {
				if (code == 1) {
					mView.onGetVersionInfoSuccess((VersionBean) data);
				} else {
					mView.onRequestFail(errorMSG);
				}
			}

			@Override
			public void onFinish() {
				mView.onFinish(WebServerContact.TYPE_VERSION);
			}
		});
	}

}
